package cn.iocoder.yudao.module.lfd.dal.mysql.appraise;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.lfd.dal.dataobject.appraise.AppraiseDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.lfd.controller.admin.appraise.vo.*;

/**
 * 评价 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface AppraiseMapper extends BaseMapperX<AppraiseDO> {

    default PageResult<AppraiseDO> selectPage(AppraisePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AppraiseDO>()
                .likeIfPresent(AppraiseDO::getNickName, reqVO.getNickName())
                .eqIfPresent(AppraiseDO::getPhone, reqVO.getPhone())
                .eqIfPresent(AppraiseDO::getShopId, reqVO.getShopId())
                .eqIfPresent(AppraiseDO::getAppointmentId, reqVO.getAppointmentId())
                .eqIfPresent(AppraiseDO::getLabel, reqVO.getLabel())
                .eqIfPresent(AppraiseDO::getDegree, reqVO.getDegree())
                .eqIfPresent(AppraiseDO::getComment, reqVO.getComment())
                .likeIfPresent(AppraiseDO::getBarberName, reqVO.getBarberName())
                .betweenIfPresent(AppraiseDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(AppraiseDO::getAvatar, reqVO.getAvatar())
                .orderByDesc(AppraiseDO::getId));
    }

    default List<AppraiseDO> selectList(AppraiseExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<AppraiseDO>()
                .likeIfPresent(AppraiseDO::getNickName, reqVO.getNickName())
                .eqIfPresent(AppraiseDO::getPhone, reqVO.getPhone())
                .eqIfPresent(AppraiseDO::getShopId, reqVO.getShopId())
                .eqIfPresent(AppraiseDO::getAppointmentId, reqVO.getAppointmentId())
                .eqIfPresent(AppraiseDO::getLabel, reqVO.getLabel())
                .eqIfPresent(AppraiseDO::getDegree, reqVO.getDegree())
                .eqIfPresent(AppraiseDO::getComment, reqVO.getComment())
                .likeIfPresent(AppraiseDO::getBarberName, reqVO.getBarberName())
                .betweenIfPresent(AppraiseDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(AppraiseDO::getAvatar, reqVO.getAvatar())
                .orderByDesc(AppraiseDO::getId));
    }

}
